import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:geomancy/api/setting.dart';
import 'package:geomancy/models/notification_list_model.dart';
import 'package:geomancy/styles/index.dart';
import 'package:geomancy/tools/constant.dart';
import 'package:geomancy/widgets/common_header.dart';
import 'package:geomancy/widgets/common_text.dart';
import 'package:geomancy/widgets/common_title.dart';

class SystemMessageDetailPage extends StatefulWidget {
  final int id;
  const SystemMessageDetailPage({super.key, required this.id});

  @override
  State<SystemMessageDetailPage> createState() => _SystemMessageDetailPageState();
}

class _SystemMessageDetailPageState extends State<SystemMessageDetailPage> {
  NotificationItemModel? msg;

  @override
  void initState() {
    super.initState();
    getMsgDetail();
  }


  Future getMsgDetail() async {
    final data = await SettingAPI.getSettingMsgDetail(context, widget.id);
    setState(() {
      msg = data;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: CommonHeader.appBar(context: context),
      backgroundColor: ColorStyle.pageDefaultColor,
      body: CustomScrollView(
        slivers: [
          //系统消息
          const SliverToBoxAdapter(
              child: CommonTitleWidget(txt: '系统消息')
          ),
          SliverPadding(
            padding: EdgeInsets.only(left: Constant.PAGEPADDING.w, right: Constant.PAGEPADDING.w, bottom: Constant.PAGEPADDING.w),
            sliver: SliverToBoxAdapter(
                child: Container(
                    margin: EdgeInsets.only(top: 20.w),
                    padding: EdgeInsets.all(40.w),
                    constraints: BoxConstraints(
                        minHeight: 400.w
                    ),
                    decoration: BoxDecoration(
                        color: ColorStyle.themeLightColor,
                        border: Border.all(width: 5.w, color: ColorStyle.borderColor),
                        borderRadius: BorderRadius.all(Radius.circular(60.w))
                    ),
                    child: Column(
                      children: [
                        Container(
                          width: double.infinity,
                          margin: EdgeInsets.only(bottom: 20.w),
                          child: CommonText(txt: msg?.createdAt ?? '', textAlign: TextAlign.right, fontSize: 26.sp),
                        ),
                        CommonText(txt: msg?.content ?? '')
                      ],
                    )
                )
            ),
          ),
        ],
      ),
    );
  }
}
